package cn.rokhdelar.ams.business.biz.project.flowablelis;

import cn.rokhdelar.ams.business.biz.project.service.BizProjectInfoService;
import jakarta.annotation.Resource;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;

/**
 * 立项审批结束监听
 * @author 范书铭
 * @date 2025年07月21日 9:33
 */
public class ProjectInitAuditEndLis implements ExecutionListener {

    @Resource
    BizProjectInfoService bizProjectInfoService;
    @Override
    public void notify(DelegateExecution execution) {
        // 流程实例结束时执行的逻辑
        String processInstanceId = execution.getProcessInstanceId();
        String processDefinitionId = execution.getProcessDefinitionId();
        // 从执行对象中获取businessKey
        String projcetCode = execution.getProcessInstanceBusinessKey();
        //获取变量:类型
        Integer auditType = execution.getVariable("auditType", Integer.class);// 1,2
        //获取变量:类型
        Boolean companyFinish = execution.getVariable("companyFinish", Boolean.class);//true,false


        bizProjectInfoService.updateStatus(  projcetCode,10);


        System.out.println("流程实例结束：" + processInstanceId);
        System.out.println("流程定义ID：" + processDefinitionId);

    }
}